package com.jtjrenren.android.taxi.passenger.core.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jtjrenren.android.taxi.passenger.R;
import com.jtjrenren.android.taxi.passenger.bean.api.DriverEvaluation;
import com.jtjrenren.android.taxi.passenger.base.BaseRcyAdapter;
import com.library.weidget.CustomFiveStars;
import com.library.utils.StringUtils;

/**
 * Created by Administrator on 2016/1/31.
 */
public class DriverEvaluaAdapter extends BaseRcyAdapter<DriverEvaluation> {
    public DriverEvaluaAdapter(Context context) {
        super(context);
    }

    @Override
    public RecyclerView.ViewHolder getItemViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_driver_eva, parent, false);

        return new EvaViewHolder(view);
    }

    @Override
    public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
        DriverEvaluation info = list.get(position);
        EvaViewHolder evaViewHolder = (EvaViewHolder) holder;
        evaViewHolder.tv_phone.setText(info.getUserTel());
        evaViewHolder.tv_date.setText(info.getTimes());
        evaViewHolder.tv_content.setText(info.getContents());

        evaViewHolder.stats.show(Integer.parseInt(StringUtils.isEmpty(info.getStars()) ? "0":info.getStars()));
    }

    public class EvaViewHolder extends RecyclerView.ViewHolder {
        TextView tv_phone, tv_date, tv_content;
        CustomFiveStars stats;

        public EvaViewHolder(View itemView) {
            super(itemView);
            tv_phone = (TextView) itemView.findViewById(R.id.item_driver_eva_phone);
            tv_date = (TextView) itemView.findViewById(R.id.item_driver_eva_date);
            tv_content = (TextView) itemView.findViewById(R.id.item_driver_eva_content);

            stats = (CustomFiveStars) itemView.findViewById(R.id.item_driver_eva_level);
        }
    }
}
